require("../../dist/index"), getApp(), require("../../utils/util.js");

var a = require("../../utils/Network.js");

Page({
    data: {
        hascard: !0,
        defaultCard: null,
        balance: "",
        patient_no: "",
        hasHospitalNo: null
    },
    onLoad: function(a) {
        wx.showShareMenu({
            withShareTicket: !0
        });
    },
    onShow: function() {
        var a = this;
        wx.showLoading({
            title: "请稍后"
        }), getApp().data.authorization ? this.activeCard(getApp().data.authorization) : getApp().getAuthorizationCallback = function(t) {
            a.activeCard(t.data.obj.Authorization), wx.setStorageSync("authorization", t.data.obj.Authorization);
        };
    },
    mzghtaped: function() {
        !0 === this.data.hascard ? wx.navigateTo({
            url: "/pages/appointmentSearch/appointmentSearch"
        }) : (wx.showLoading({
            title: "请绑定就诊卡"
        }), setTimeout(function() {
            wx.hideLoading();
        }, 1500));
    },
    zjjftaped: function() {
        !0 === this.data.hascard ? wx.navigateTo({
            url: "/pages/zjjf/zjjf"
        }) : (wx.showLoading({
            title: "请绑定就诊卡"
        }), setTimeout(function() {
            wx.hideLoading();
        }, 1500));
    },
    mzcztaped: function() {
        wx.showLoading({
            title: "功能升级中"
        }), setTimeout(function() {
            wx.hideLoading();
        }, 1500);
    },
    mzbgtaped: function() {
        var a = this;
        if ("" == this.data.patient_no) return wx.showLoading({
            title: "请绑定住院号"
        }), void setTimeout(function() {
            wx.hideLoading(), wx.navigateTo({
                url: "/pages/cardDetail/cardDetail?navindex=1&cardno=" + a.data.defaultCard.cardNo
            });
        }, 2e3);
        !0 === this.data.hascard ? wx.navigateTo({
            url: "/pages/mzbg/mzbg?navindex=2"
        }) : (wx.showLoading({
            title: "请绑定就诊卡"
        }), setTimeout(function() {
            wx.hideLoading();
        }, 1500));
    },
    binglitaped: function() {
        var a = this;
        if ("" == this.data.patient_no) return wx.showLoading({
            title: "请绑定住院号"
        }), void setTimeout(function() {
            wx.hideLoading(), wx.navigateTo({
                url: "/pages/cardDetail/cardDetail?navindex=1&cardno=" + a.data.defaultCard.cardNo
            });
        }, 2e3);
        if (!0 === this.data.hascard) {
            var t = JSON.stringify(this.data.defaultCard);
            wx.navigateTo({
                url: "/pages/blsq/blsq?cardinfo=" + t
            });
        } else wx.showLoading({
            title: "请绑定就诊卡"
        }), setTimeout(function() {
            wx.hideLoading();
        }, 1500);
    },
    wdghtaped: function() {
        !0 === this.data.hascard ? wx.navigateTo({
            url: "/pages/myregistered/myregistered"
        }) : (wx.showLoading({
            title: "请绑定就诊卡"
        }), setTimeout(function() {
            wx.hideLoading();
        }, 1500));
    },
    zyqdtaped: function() {
        var a = this;
        if ("" == this.data.patient_no) return wx.showLoading({
            title: "请绑定住院号"
        }), void setTimeout(function() {
            wx.hideLoading(), wx.navigateTo({
                url: "/pages/cardDetail/cardDetail?navindex=1&cardno=" + a.data.defaultCard.cardNo
            });
        }, 2e3);
        !0 === this.data.hascard ? wx.navigateTo({
            url: "/pages/mzqd/mzqd?index=2"
        }) : (wx.showLoading({
            title: "请绑定就诊卡"
        }), setTimeout(function() {
            wx.hideLoading();
        }, 1500));
    },
    zyzdtaped: function() {
        var a = this;
        if ("" == this.data.patient_no) return wx.showLoading({
            title: "请绑定住院号"
        }), void setTimeout(function() {
            wx.hideLoading(), wx.navigateTo({
                url: "/pages/cardDetail/cardDetail?navindex=1&cardno=" + a.data.defaultCard.cardNo
            });
        }, 2e3);
        !0 === this.data.hascard ? wx.navigateTo({
            url: "/pages/wdzd/wdzd?index=2"
        }) : (wx.showLoading({
            title: "请绑定就诊卡"
        }), setTimeout(function() {
            wx.hideLoading();
        }, 1500));
    },
    mydctaped: function() {
        wx.showLoading({
            title: "请查看微信通知"
        }), setTimeout(function() {
            wx.hideLoading();
        }, 1500);
    },
    yndhtaped: function() {
        wx.showLoading({
            title: "暂未开放"
        }), setTimeout(function() {
            wx.hideLoading();
        }, 1500);
    },
    mztktaped: function() {
        !0 === this.data.hascard || (wx.showLoading({
            title: "请绑定就诊卡"
        }), setTimeout(function() {
            wx.hideLoading();
        }, 1500));
    },
    jzkgltaped: function() {
        wx.navigateTo({
            url: "/pages/mycards/mycards"
        });
    },
    bdzyhtaped: function() {
        wx.navigateTo({
            url: "/pages/cardDetail/cardDetail?navindex=1&cardno=" + this.data.defaultCard.cardNo
        });
    },
    activeCard: function(t) {
        var i = this;
        a.requestForHeader("/api/patient/activeCard", {}, "GET", t).then(function(a) {
            "ok" == a.data.state ? (i.setData({
                defaultCard: a.data.obj,
                patient_no: a.data.obj.hospitalNo,
                hascard: !0
            }), i.getBalance(a.data.obj.cardNo), wx.setStorageSync("defaultCard", a.data.obj)) : i.setData({
                defaultCard: {},
                hascard: !1
            }), wx.hideLoading();
        }).catch(function(a) {
            console.log("请求失败！" + a), wx.hideLoading();
        });
    },
    getBalance: function(t) {
        var i = this;
        a.requestByHeader("/api/patient/card", {
            cardNo: t
        }, "GET").then(function(a) {
            "ok" == a.data.state && i.setData({
                balance: a.data.obj.zyAccBalance
            });
        }).catch(function(a) {
            console.log("请求失败！" + a);
        });
    },
    bindcard: function() {
        wx.navigateTo({
            url: "/pages/addcard1/addcard1"
        });
    },
    formSubmit: function(a) {
        wx.navigateTo({
            url: "/pages/thanksuser/thanksuser?index=2"
        });
    }
});